class MemberCoupon < ApplicationRecord
  module UnionHack
    def union(*relations)
      from '((' + relations.map { |r| r.to_sql }.join(') UNION (') + ')) AS ' + self.table_name
    end
  end
  extend UnionHack
  belongs_to :member
  belongs_to :coupon

  enum status: [:pending, :used]
  enum kind: [:novice, :normal, :share]
end
